using UnityEngine;
using System.Collections;

public class MenuManager : MonoBehaviour 
{
	public SceneChangeSettings[] sceneChanges;
	public float amount;
	public float standTime;
	public Menu Pc;
	public AndroidMenu Android;
	public bool needFadeIn;
	
	IEnumerator Start()
	{
		yield return new WaitForSeconds(standTime);
		gameObject.SendMessage("Ready",SendMessageOptions.DontRequireReceiver);
	}
	
	
	void Awake()
	{
		if(Application.loadedLevelName.StartsWith("Level"))
		{
		}
		else
		{
			if(!Application.loadedLevelName.Equals("Tutorial"))
			{
				gameObject.AddComponent("FadeIn");
				gameObject.GetComponent<FadeIn>().createFade(amount);
			}
		}
		
		#if UNITY_STANDALONE_WIN || UNITY_WEBPLAYER
		
		Android.enabled = false;
		
		#endif
		
		#if UNITY_IPHONE || UNITY_ANDROID
		
		Pc.enabled = false;
		
		#endif

	}
	
	public void changeSceneAtName(string sceneName)	
	{
		gameObject.AddComponent("SceneChange");
				
		if(gameObject.GetComponent<SceneChange>().existFade())
		{
			gameObject.GetComponent<SceneChange>().createFade(sceneName,amount);
		}
	}
	
	public void changeScene(string objectName)
	{
		foreach(SceneChangeSettings settings in sceneChanges)
		{
			if(settings.gameObjectName.Equals(objectName))
			{
				gameObject.AddComponent("SceneChange");
				
				if(gameObject.GetComponent<SceneChange>().existFade())
				{
					gameObject.GetComponent<SceneChange>().createFade(settings.sceneName,amount);
				}
				
				break;
			}
		}
	}
	
	[System.Serializable]
	public class SceneChangeSettings
	{
		public string sceneName;
		public string gameObjectName;
	}
}
